const Koa = require("koa")
const app = new Koa()
const {secretKey} = require("./config")
const path = require("path")
var koaJwt = require("koa-jwt");
app.use(
koaJwt({ secret: secretKey }).unless({ path: [/\/news/] })
);

//post
const bodyParser = require("koa-bodyparser")
app.use(bodyParser())

//跨域
const cors = require("@koa/cors")
app.use(cors())

const render = require('koa-art-template');

render(app, {
  root: path.join(__dirname, 'view'),
  extname: '.art',
//   debug: process.env.NODE_ENV !== 'production'
});

const newsRouter = require('./router/news')
app.use(newsRouter.routes())


app.listen(3000)